/*
 *	(*^。^*) TFrameWork License (*^。^*)
 */

/*
 *  Title :
 *
 *  Description :
 *
 *
 *  Date :
 *
 *  Author : DengPing
 *
 *  Modify :
 */
using UnityEngine;

namespace TFrameWork.Module.ActionEditor
{
    public class CustomOnAudioTrack : CustomOnRecordTrack,IOnAudioTrack
    {
        private GameObject audio;
        private AudioSource audioSource;
        
        public override void Init(TimeLineAction timeLineAction)
        {
            base.Init(timeLineAction);
            audio = new GameObject(nameof(CustomOnAudioTrack));
            audio.hideFlags = HideFlags.DontSave;
            audioSource = audio.AddComponent<AudioSource>();
        }
        
        public override void OnStart(TrackEventBase data)
        {
            base.OnStart(data);
            var audioData = data as AudioEvent;
            audioSource.clip = audioData.audioClip;
            audioSource.Play();

        }
    }
}